import React from 'react';
import { TopViewProvider } from '../components/TopView';
interface Props {
	providers: React.ComponentType<any>[];
	onload?: () => void;
}
const AppProvider: React.FC<Props> = props => {
	let { providers = [], children } = props;
	providers = [TopViewProvider, ...providers];
	const createProvider = () => {
		for (let i = providers.length - 1; i >= 0; i--) {
			let Provider = providers[i];
			children = <Provider>{children}</Provider>;
		}
		return <React.Fragment>{children}</React.Fragment>;
	};

	return <React.Fragment>{createProvider()}</React.Fragment>;
};
export default AppProvider;
